package com.snpic.appaw.module.third.enums.jpush;


/**
 * @author JiJun
 * @date 2025/9/10 16:14
 * @修改时间 2025/9/10 16:14
 * @description 极光认证,返回码说明,枚举类
 */
public enum JVerificationEnum {
	SUCCESS(0, "请求成功"),
	INVALID_PARAMETERS(1801, "参数异常或不合法"),
	AUTH_FAILED(1802, "认证失败"),
	NO_PERMISSION(1803, "权限不足，服务未开通或已到期"),
	QPS_LIMIT(1804, "QPS 限流"),
	INSUFFICIENT_BALANCE(1805, "余额不足"),
	INTERNAL_ERROR(2000, "内部服务器错误"),
	CAPTCHA_ID_NOT_EXIST(6003, "captcha_id 不存在"),
	CAPTCHA_ID_NOT_BIND(6004, "captcha_id 没有绑定"),
	BEYOND_HOUR_FREQUENCY_LIMIT(6005, "同一 AppKey 自然小时内认证次数超过限制"),
	RUNTIME_ERROR(7101, "非正常流程导致的未定义错误"),
	ILLEGAL_RISK_TYPE(7102, "风控模式下传入非法的 risk_type 参数"),
	PARAM_DECRYPT_ERROR(7103, "非法加密参数引起的解密流程异常"),
	ILLEGAL_VERIFY(7104, "重复进行验证"),
	JSONP_XSS(7105, "异常"),
	NOT_CAPTCHA_ID(7106, "缺少验证 id"),
	ILLEGAL_CAPTCHA_ID(7107, "非法的验证 id"),
	NOT_CAPTCHA(7108, "不存在的验证 id"),
	CAPTCHA_ID_DELETED(7109, "已删除的验证 id"),
	NOT_PROOF(7110, "流水号信息不存在，缓存过期失效"),
	NOT_LOT_NUMBER(7111, "缺少流水号"),
	ILLEGAL_LOT_NUMBER(7112, "非法的流水号"),
	GET_PHONE_SUCCESS(8000, "获取一键登录的手机号码成功"),
	GET_PHONE_FAIL(8001, "获取一键登录的手机号码失败"),
	VERIFY_CONSISTENT(9000, "手机号验证一致"),
	VERIFY_NOT_CONSISTENT(9001, "手机号验证不一致"),
	UNKNOWN_RESULT(9002, "结果未知"),
	TOKEN_EXPIRED_OR_NOT_EXIST(9003, "token 失效或不存在"),
	CONFIG_NOT_FOUND(9004, "获取配置失败"),
	VERIFY_INTERVAL_LESS_THAN_MIN_LIMIT(9005, "同一号码连续两次提交认证间隔过短"),
	FREQUENCY_OF_VERIFYING_SINGLE_NUMBER_BEYOND_MAX_LIMIT(9006, "同一号码自然日内认证次数超过限制"),
	BEYOND_DAILY_FREQUENCY_LIMIT(9007, "appKey 自然日认证消耗超过限制"),
	MISS_AUTH(9010, "缺少鉴权信息"),
	AUTH_FAILED_2(9011, "鉴权失败"),
	PARAMETER_INVALID(9012, "参数错误"),
	REQUEST_METHOD_NOT_SUPPORTED(9013, "请求方式错误，请用 POST 请求"),
	APPKEY_IS_BLOCKED(9014, "功能被禁用"),
	HTTP_MEDIA_TYPE_NOT_SUPPORTED(9015, "请检查 Content type 类型"),
	APPKEY_NO_MONEY(9018, "账户余额不足"),
	APPKEY_NO_QUOTA(9019, "应用可用额度不足"),
	DECRYPT_TOKEN_FAILED(9020, "解密 token 失败，请检查 appkey 是否正确"),
	TOKEN_INVALID(9021, "token 非法，请确认 token 获取正确"),
	ENCRYPT_MOBILE_FAILED(9022, "加密号码失败，请检查 RSA 公钥是否正确"),
	NOT_VALIDATE_USER(9031, "未开通认证服务"),
	BAD_SERVER(9099, "服务器未知错误"),
	SIGNONCE_OPENED_SUCCESS(9200, "一键登录开通成功"),
	APPKEY_NOT_EXISTS(9202, "appKey 不存在"),
	SIGNONCE_OPENED_ALREADY(9203, "一键登录已开通"),
	SIGNONCE_OPENED_FAILED(9301, "一键登录开通失败");

	private final int code;
	private final String description;

	JVerificationEnum(int code, String description) {
		this.code = code;
		this.description = description;
	}

	public int getCode() {
		return code;
	}

	public String getDescription() {
		return description;
	}

	public static String getDescriptionByCode(int code) {
		for (JVerificationEnum errorCode : JVerificationEnum.values()) {
			if (errorCode.getCode() == code) {
				return errorCode.getDescription();
			}
		}
		return "未知错误码";
	}
}
